package com.eeepay.eeepay_v2.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.eeepay.eeepay_v2.R;
import com.eeepay.v2_library.util.ABAppUtil;

/**
 * 描述：温馨提示语
 * 作者：zhuangzeqin
 * 时间: 2017/6/7-17:47
 * 邮箱：zzq@eeepay.cn
 */

public class TipMsgDialog extends Dialog implements View.OnClickListener {
    private Context mContext;
    private Button button;
    private ImageView cancleIv;//取消
    private TextView tv_tipmsg;//提示语

    private String mTipMsg;//温馨提示；外面的提供


    private OnConfirmListener onClickListener;

    public TipMsgDialog(Context context) {
        super(context, R.style.dialog_custom_style);
        this.mContext = context;

    }

    public void setTipMsg(String msg) {
        this.mTipMsg = msg;
        init();

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    private void init() {
        setContentView(R.layout.dialog_tip_msg);
        button = (Button) findViewById(R.id.btn_confirm);
        cancleIv = (ImageView) findViewById(R.id.iv_cancle);
        tv_tipmsg = (TextView) findViewById(R.id.tv_tipmsg);
        tv_tipmsg.setText(mTipMsg);
        button.setOnClickListener(this);
        cancleIv.setOnClickListener(this);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_cancle:
                ABAppUtil.hideSoftInput(mContext);
                super.dismiss();
                break;
            case R.id.btn_confirm:
                if (onClickListener!=null)
                    onClickListener.onConfirm();
                super.dismiss();
                break;
        }
    }


    public interface OnConfirmListener {
        void onConfirm();
    }

    public void setConfirmListener(OnConfirmListener onClickListener) {
        this.onClickListener = onClickListener;
    }
}
